﻿using FlexFlow.Model;
using FlexFlow.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace FlexFlow.MVC.Controllers
{
    /// <summary>
    /// 表示工作流核心界面控制器
    /// </summary>
    public class FlexFlowController : Controller
    {
        //
        // GET: /FlexFlow/
        /// <summary>
        /// 开始流程界面
        /// </summary>
        /// <param name="procId">
        /// 流程Id
        /// </param>
        /// <returns></returns>
        public ActionResult StartProcess(Guid procId)
        {
            OperateResult procGetRes = ProcessDefineManager.Default.GetProcessById(procId);
            if (procGetRes.ResultCode != 200)
            {
                return Json(procGetRes);
            }
            return View(procGetRes.Tag);
        }
        /// <summary>
        /// 显示任务详细界面
        /// </summary>
        /// <param name="taskId">
        /// 任务ID
        /// </param>
        /// <returns></returns>
        public ActionResult TaskDetail(Guid taskId)
        {
            OperateResult res = WorkFlowEngine.Default.OpenTask(taskId);
            if (res.ResultCode!=200)
            {
                return Content(res.Message + "[" + res.ResultCode + "]");
            }
            else
            {
                return View(res.Tag);
            }
        }
        /// <summary>
        /// 显示流程步骤界面
        /// </summary>
        /// <param name="procInsId">
        /// 流程实例id
        /// </param>
        /// <returns></returns>
        public ActionResult FlowSetp(Guid procInsId)
        {
            return View();
        }
    }
}
